<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>

    <th:block th:include="include :: header('定时任务新增')"/>
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<form action="" class="layui-form layuimini-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red;">*</span>名称</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" lay-verify="required" name="jobName" placeholder="任务名称"
                           type="text">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red;">*</span>任务</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" lay-verify="required" name="beanName" placeholder="运行类"
                           type="text">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">参数</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" name="params" placeholder="执行表达式"
                           type="text">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red;">*</span>Cron</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" id="cronExpression" lay-verify="required"
                           name="cronExpression" placeholder="0/5 * * * * ?" type="text">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input name="status" title="运行" type="radio" value="0">
                    <input checked name="status" title="挂起" type="radio" value="1">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="remark" placeholder="任务描述"></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button class="layui-btn layui-btn-sm" lay-filter="role-save" lay-submit="" type="submit">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button class="layui-btn layui-btn-primary layui-btn-sm" type="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(role-save)', function (data) {
            let loading = layer.load();
            $.ajax({
                url: pName + '/system/job/save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    layer.close(loading);
                    if (result.code == 1) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("job-table");
                        });
                    } else {
                            layer.alert(result.msg, {icon: 2});
                        }
                }
            });
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>